//
//  UIButton+Extension.swift
//  ydy_weibo
//
//  Created by 杨德勇 on 16/7/17.
//  Copyright © 2016年 杨德勇. All rights reserved.
//

import UIKit

extension UIButton{
    convenience init(title:String?,backimg:String?,color:UIColor?,image : String? = "",fontsize:CGFloat = 14){
        self.init()
        if title != nil {
            setTitle(title, forState: .Normal)
            
        }
        
        if backimg != nil {
            setBackgroundImage(UIImage(named: backimg!), forState: .Normal)
            setBackgroundImage(UIImage(named: backimg! + "_highlighted"), forState: .Normal)
           
        }
        
        if color != nil {
            setTitleColor(color, forState: .Normal)
        }
        titleLabel?.font = UIFont.systemFontOfSize(fontsize)
        setImage(UIImage(named: image!), forState: .Normal)
    }
}
